<template>
  <div class="scheduling-system" v-loading="loading" element-loading-text="加载中。。。">
    <!-- <el-card> -->
      <el-row :gutter="10">
        <el-col :span="6">
           <el-card style='height:800px;overflow:auto' shadow="never">
            <div style="margin-bottom: 10px;">机构名称</div>
            <div class="block">
              <!-- 机构 -->
              <select-tree :tree-data="treedata" :branch="BRANCHNAME" @getBranchName="getBranch"></select-tree>
            </div>
           
            <el-divider></el-divider>
            <!-- 用户列表 -->
            <div v-if="userData.length>0">
              <el-checkbox :indeterminate="isIndeterminate" border v-model="checkAll"
                @change="handleCheckAllChange" style="width:78%;">全选</el-checkbox>
              <el-checkbox-group v-model="checkedRole"  v-if="userData.length>0" @change="handleCheckedCitiesChange">
                <el-checkbox v-for="(item,index) in userData" @change="getUserInfo(item)" 
                  :label="item.AGENTID" :key="index" border >
                  <span class="agentStyle">
                  {{item.AGENTNAME}}
                  </span>
                  <span v-if="item.color==true" class="extraBranchStyle">{{item.color==true?'附':''}}</span>
                  </el-checkbox>
              </el-checkbox-group>
              <div style="margin-left: 20px" v-if="userData.length>0">
                <!-- <el-button type="primary" size="small" @click="queryModel(startStr,endStr1);" :disabled="checkedRole.length==0 || isPlanMaintain">查看</el-button> -->
                <el-button size="small" @click="checkedRole=[];checkAll=false" type="danger">取消选择</el-button>
              </div>
            </div>
            <div v-else style="text-align:center;margin-top:20px;">暂无数据</div>
          </el-card>
        </el-col>
        <el-col :span="18">
          <el-card>
            <div :style="moveStyle">{{msg}}</div>
            <div>
              <el-button type="primary" size="small" @click="openCreateClass" :disabled="checkedRole.length==0 || isPlanMaintain">班表生成</el-button>
              <el-button type="primary" size="small" @click="scheduleRelease">发布班表</el-button>
              <el-button type="warning" size="small" @click="warnOptions.isShow=true" :disabled="isPlanMaintain">告警信息</el-button>
            </div>
            <!-- <el-divider></el-divider> -->
            <el-alert title="周试图下不允许进行修改哦~" 
              type="warning" v-show="view=='week'" 
              style="margin-bottom: 20px;">
            </el-alert>
            <el-row>
              <div style="margin-top:20px;">排班计划名称</div>
              <el-col :span="8">
                  <!-- 排班计划 -->
                <el-select v-model="PlanMaintain" size="small" placeholder="请选择排班计划" style="margin-top: 10px;">
                  <el-option
                    v-for="(item,index) in tableDataPlan"
                    :key="index"
                    :label="item.SPNAME"
                    :value="item.SPID">
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="6" style="margin: 10px 0 0 20px">
                <el-button type="primary" size="small" @click="queryModel(startStr,endStr1);" :disabled="checkedRole.length==0 || isPlanMaintain">查看班表</el-button>

              </el-col>
              <div>
              
                
              </div>
            </el-row>
            
            <el-divider></el-divider>
             <template>
               <!-- 
                  :select-allow="handlerSeelctAllow"
                  aspectRatio="100" 
                  scrollTime="00:00"
                  :slotDuration='slotDuration'
                  :resourceColumns="resourceColumns"
                -->
              <FullCalendar
                ref="calendar"
                locale='zh-cn'
                :defaultDate="defaultDate"
                :defaultView="defaultView" 
                :plugins="calendarPlugins" 
                :resourceLabelText="resourceLabelText"
                :resources="resources"
                :header="header"
                :resourceAreaWidth="resourceAreaWidth"
                :views="views"
                :selectHelper="true"
                :select-mirror="true"
                :droppable="true"
                scrollTime="08:00"
                :editable="editable"
                :navLinks="false"
                :unselect-auto="true"
                :select-overlap="true"
                :slotEventOverlap="true"
                :eventOverlap="false"
                :eventStartEditable="eventStartEditable" 
                :eventDurationEditable="eventDurationEditable"
                :selectable="selectable"
                :displayEventEnd="true"
                :displayEventTime="true"
                :eventTimeFormat="eventTimeFormat"
                :weekNumberTitle="weekNumberTitle"
                :buttonText="buttonText"
                :events="events"
                :dayRender="dayRender"
                @dateClick="dateClick"
                @select="select"
                @eventClick="eventClick"
                @eventDrop="eventDrop"
                @eventDragStart="eventDragStart"
                @dayClick="dayClick"
                @eventMouseEnter="eventMouseEnter"
                @eventMouseLeave="eventMouseLeave"
                @eventResizeStop ="eventResizeStop"
                @eventResize="eventResize"
                @eventResizeStart="eventResizeStart"/>
            </template>
          </el-card>
        </el-col>
      </el-row>
      <!-- 新增和编辑事件弹窗 -->
      <!-- <el-dialog :title="dialogTitle" width="60%"
        :visible.sync="dialogVisible"
        @close="closeDialog('ruleForm')" @open="openDialog" 
        :close-on-click-modal="false">
        <el-card>
          <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px">
            <el-row>
              <el-col :span="16">
                <el-form-item label="排班计划编号" prop="SPID">
                  <el-input v-model="ruleForm.SPID" size="small" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="16">
                <el-form-item label="坐席编号" prop="AGENTID">
                  <el-input v-model="ruleForm.AGENTID" size="small" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="16">
                <el-form-item label="班次日期" prop="CLASSESDATE">
                  <el-date-picker
                    v-model="ruleForm.CLASSESDATE"
                    type="date"
                    format="yyyy-MM-dd"
                    value-format="yyyyMMdd"
                    placeholder="选择日期"
                    @blur="DateFocus"
                    :clearable="false"
                    :disabled="view==='week'">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="16">
                <el-form-item label="班次名称" prop="ClassNAME">
                  <el-select v-model="ruleForm.ClassNAME" clearable placeholder="请选择" @change="handleClassChange" :disabled="ruleForm.OTNAME != undefined&&ruleForm.OTNAME!=''||view==='week'">
                    <el-option
                      v-for="(item,index) in tableDataClass"
                      :key="item.CLASSESID"
                      :label="item.CLASSESNAME"
                      :value="item.CLASSESID">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item label="加班名称" prop="OTNAME">
                  <el-select v-model="ruleForm.OTNAME" placeholder="请选择" clearable @change="handleOTChange" :disabled="ruleForm.ClassNAME != undefined&&ruleForm.ClassNAME!=''||view==='week'">
                    <el-option
                      v-for="(item,index) in tableDataOT"
                      :key="item.OTID"
                      :label="item.OTNAME"
                      :value="item.OTID">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item label="班次事件名称" prop="ClassEventName">
                  <el-select v-model="ruleForm.ClassEventName" placeholder="请选择" clearable @change="handleClassEventChange" :disabled="view==='week'">
                    <el-option
                      v-for="(item,index) in tableDataClassEvent"
                      :key="item.CLASSESEVENTID"
                      :label="item.CLASSESEVENTNAME"
                      :value="item.CLASSESEVENTID">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item label="开始时间" prop="SRTTIME">
                  <el-time-picker size="small" style="width:100%;" 
                    :disabled="view==='week'"
                    :clearable="false"
                    v-model="ruleForm.SRTTIME" placeholder="请选择开始时间"
                    format="HH:mm"
                    value-format="HH:mm"
                    @blur="DateFocus"
                    @focus="ruleForm.SRTTIME===null || ruleForm.SRTTIME===''?ruleForm.SRTTIME='00:00':ruleForm.SRTTIME;DateFocus()">
                  </el-time-picker>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item label="结束时间" prop="ENDTIME">
                  <el-time-picker size="small" style="width:100%;" 
                    :disabled="view==='week'"
                    :clearable="false"
                    v-model="ruleForm.ENDTIME" placeholder="请选择开始时间"
                    format="HH:mm"
                    value-format="HH:mm"
                    @blur="DateFocus"
                    @focus="ruleForm.ENDTIME===null || ruleForm.ENDTIME===''?ruleForm.ENDTIME='00:00':ruleForm.ENDTIME;DateFocus()">
                  </el-time-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-card>
        <div slot="footer" class="dialog-footer" v-if="view=='day'">
          <el-button @click="closeDialog('ruleForm')" size="mini">取 消</el-button>
          <el-button type="primary" @click="submitForm('ruleForm')" size="mini">确 定</el-button>
          <el-button type="danger" @click="scheduleDel()" size="mini" v-show="op=='edit'">删 除</el-button>
        </div>
      </el-dialog> -->
      <!-- 班次/加班下得详细班次事件 -->
      <el-dialog  title="详细班次事件信息" width="60%" :visible.sync="dialogVisible"
        @close="closeDialog" @open="openDialog" :close-on-click-modal="false"
      >
        <el-card>
          <!-- <el-button type="primary" size="mini" style="margin-bottom:10px;" @click="addClick">新增关联班次事件</el-button> -->
          <el-table :data="tableDataDetail.SCHEDULELIST" style="width: 100%">
            <el-table-column prop="AGENTID" label="坐席编号" align="center"></el-table-column>
            <el-table-column prop="CLASSESDATE" label="班次日期" align="center"></el-table-column>
            <el-table-column prop="" label="类别" align="center">
              <template slot-scope="scope"> 
                <div>
                  {{scope.row.TOACTIVITYID == ''?(scope.row.TOACTIVITYCATEG==''?'班次':'加班'):'班次事件'}}
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="ACTIVITYID" label="活动编号" align="center" width="120"></el-table-column>
            <el-table-column prop="ACTIVITYNAME" label="活动名称" align="center"></el-table-column>
            <el-table-column prop="SRTTIME" label="开始时间" align="center"></el-table-column>
            <el-table-column prop="ENDTIME" label="结束时间" align="center"></el-table-column>
            <el-table-column prop="SKILLFLG" label="技能" align="center"></el-table-column>
            <el-table-column label="操作" fixed="right" width="180" align="center">
              <template slot-scope="scope">
                <el-button type="text" size="small" @click="operation(scope.row,'edit')">修改</el-button>
                <el-button type="text" size="small" @click="operation(scope.row,'del')">删除</el-button>
                <el-button v-if="scope.row.TOACTIVITYID ==''" type="text" size="small"  @click="addClick(scope.row)">新增班次事件</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible=false" size="mini">取 消</el-button>
          <el-button type="danger" @click="operation(ruleFormDetail,'allDel')" size="mini">删 除</el-button>
        </div>
      </el-dialog>
      <!-- 班表生成弹窗 -->
      <component :is="dialogList.setAlgorithm" :option="setOptions"></component>
      <!-- 告警弹窗 -->
      <component :is="dialogList.warnInfo" :option="warnOptions"></component>
      <!-- 新增和编辑事件弹窗 -->
      <component :is="dialogList.editSchedule" :option="editOptions" ref="mychild"></component>
    <!-- </el-card> -->
  </div>
</template>

<script>
import { Calendar } from '@fullcalendar/core';
import resourceTimelinePlugin from '@fullcalendar/resource-timeline';
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import timeGridPlulgin from '@fullcalendar/timegrid'
import '@fullcalendar/core/locales/zh-cn' // 支持中文
import momentPlugin from '@fullcalendar/moment'
import interactionPlugin from '@fullcalendar/interaction'
import toolBox from '@/common/utils/toolBox';
import selectTree from "@/components/selectTree5/";
import setAlgorithm from './dialog/setAlgorithm';
import warnInfo from './dialog/warnInfo';
import editSchedule from './dialog/editSchedule';
// 通讯相关
import request from "@/common/utils/requestWFM";
import scheduleQuery from "@/message/wfm/intelligenceSchedule/scheduleReport/scheduleQuery";
import scheduleAdd from "@/message/wfm/intelligenceSchedule/scheduleReport/scheduleAdd";
import scheduleEdit from "@/message/wfm/intelligenceSchedule/scheduleReport/scheduleEdit";
import scheduleDel from "@/message/wfm/intelligenceSchedule/scheduleReport/scheduleDel";
import scheduleRelease from "@/message/wfm/intelligenceSchedule/scheduleReport/scheduleRelease";

import userQuery from '@/message/wfm/baseData/userManage/userQuery';
import actQuery from '@/message/wfm/scheduleDataManage/activityManage/actQuery';
import queryPlanMaintain from '@/message/wfm/intelligenceSchedule/planMaintain/queryPlanMaintain';
import classQuery from '@/message/wfm/scheduleDataManage/classManage/classQuery';
import classEventQuery from '@/message/wfm/scheduleDataManage/classEventManage/classEventQuery';
import queryOTDelay from '@/message/wfm/scheduleDataManage/OTDelayManage/queryOTDelay';
import auxNoQuery from "@/message/wfm/intelligenceSchedule/scheduleReport/auxNoQuery";
  import dataQuery from '@/message/wfm/baseData/dictionaryManage/dictionaryQuery'

export default {
  name: "scheduling-system",
  components: {
    FullCalendar,
    selectTree
  },
  data() {
    return {
      skillOption:[],//技能
      loading: false,
      calendarPlugins: [resourceTimelinePlugin,momentPlugin,interactionPlugin,dayGridPlugin],
      defaultDate: new Date(),
      editable: true, 
      selectable: true,
      eventStartEditable: true,
      eventDurationEditable: true,
      // slotLabelFormat: {
      //   hour: 'numeric',
      //   minute: '2-digit',
      //   omitZeroMinute: true,
      //   meridiem: 'short',
      //   hour12: false,
      // },
      // 确定将在每个事件上显示的时间文本
      eventTimeFormat: {
        hour: 'numeric',
        minute: '2-digit',
        meridiem: 'narrow',
        hour12: false,
      },
      // scrollTime: '09:00',
      defaultView: "resourceTimelineDay",
      resourceLabelText: '人员安排',
      header: {
        left: 'prev,next, today',
        center: 'title',
        right: 'resourceTimelineDay,resourceTimelineWeek,'
      },
      // slotDuration: '00:15:00',
      weekNumberTitle:'1',
      // 左侧人员列表
      resources: [],
      eventsDay: [],
      eventsWeek: [],
      resourceAreaWidth: '15%',
      // 左上角行
      resourceColumns: [
        {
          labelText: '',
          field: 'title'
        },
      ],
      views: {
        resourceTimelineDay: {
          buttonText: '日',
          slotDuration: '00:15:00',
          slotLabelFormat:"HH:mm",
        },
        resourceTimelineWeek: {
          type: 'resourceTimeline',
          slotDuration: '24:00:00',
          buttonText: '周',
        },
        dayGridMonth: {
          buttonText: '月',
        }
      },
      buttonText: {
        today: "今天",
      },
      dialogVisible: false,
      // 添加事件标题
      selectInfo: [],
      // 获取到展示日历得起始时间
      startStr:'',
      endStr:'',
      endStr1: '',
      // day--日视图   week--周视图
      view: 'day',
      tableData:[],
      tableDataDetail:[],  //班次/加班下的班次事件查询
      ruleFormDetail:[],  //班次/加班下的班次事件查询
      // 修改编辑弹窗
      dialogTitle: '',
      ruleForm: {
        SPID: '',
        AGENTID: '',
        ClassNAME: '',
        ClassEventName: '',
        OTName: '',
        CLASSESDATE: '',
        ACTIVITYTYPE: '',
        ACTIVITYID: '',
        SRTTIME: '',
        ENDTIME: '',
        TOACTIVITYID: '',
        TOACTIVITYNAME: '',
        TOACTIVITYCATEG: '',
        TOACTIVITYTYPE: '',
      },
      rules: {
        CLASSESDATE: [{required: true,message: '请输入班次日期',trigger: 'blur'}],
        ACTIVITYTYPE: [{required: true,message: '请输入活动类型编号',trigger: 'blur'}],
        SRTTIME: [{required: true,message: '请选择开始日期',trigger: 'change'}],
        ENDTIME: [{required: true,message: '请选择结束日期',trigger: 'change'}],
      },
      ruleFormBack: {},
      // 左侧参数
      BRANCHNO: this.$store.getters.BranchNum,
      BRANCHNAME: this.$store.getters.BranchName,
      treedata: [],
      defaultProps: {
        children: 'children',
        label: 'BRANCHNAME'
      },
      checkedRole: [],  //选中用户
      userData: [],
      usertableData: [],
      branchData: [],
      tableDataPlan: [], //排班数据
      PlanMaintain: '',
      isPlanMaintain: true,
      // 全选
      isIndeterminate: true,
      checkAll: false,
      // 弹窗
      dialogList: { setAlgorithm,warnInfo,editSchedule},
      setOptions:{
        isShow:false,
        title: '班表生成',
      },
      warnOptions:{
        isShow:false,
        title: '告警信息',
      },
      editOptions:{
        isShow: false,
        title: '',
        row:{}
      },
      classManage: false,
      classEventManage: false,
      tableDataClass: [],  // 班次数据
      tableDataClassEvent: [],  // 班次事件数据
      tableDataOT: [],//加班数据
      tableDataAct: [], //活动类型大类数据
      // 选择班次时拿到选中得班次所有信息
      classAllInfo: [],
      classEventAllInfo: [],
      OTAllInfo: [],
      op: '',  // 新增or编辑or查看
      msg: '',
      moveStyle:{  
        display: 'none'  
      },
      allUser:[],  //所有用户
      myShow: false,

    };
  },
  watch:{
    dialogVisible(val){
      if(val){
        this.queryModel1();
      }
    },
    // 时间改变则查询新的班表
    startStr(val){
      if(this.PlanMaintain && this.checkedRole.length>0){
        this.queryModel();
      }
    },
    PlanMaintain(val){
      if(val){
        this.isPlanMaintain = false;
      }else{
        this.isPlanMaintain = true;
      }
    },
    userData(val){
      this.allUser = [];
      this.userData.forEach(item=>{
        this.allUser.push(item.AGENTID);
      })
    },
    'editOptions.isShow':function(val){
      if(val){
        this.editOptions.row.op = this.op;
        this.editOptions.row.view = this.view;
        this.editOptions.row.BRANCHNO = this.BRANCHNO;
        this.editOptions.row.tableDataClass = this.tableDataClass;
        this.editOptions.row.tableDataOT = this.tableDataOT;
        this.editOptions.row.tableDataAct = this.tableDataAct;
        this.editOptions.row.classAllInfo = this.classAllInfo;
        this.editOptions.row.classEventAllInfo = this.classEventAllInfo;
        this.editOptions.row.OTAllInfo = this.OTAllInfo;
        this.editOptions.myShow = this.myShow;
      }else{
        this.ruleForm = {},
        this.ruleFormBack = {};
        this.classAllInfo = [];
        this.classEventAllInfo = [];
        this.OTAllInfo = [];
        this.tableDataClassEvent = [];
      }
    },     
  },
  computed:{
    events(arg) {  
      // 默认日期
      this.defaultDate = new Date();
      // 日期转还为事件戳，相减算出天数 endStr --> YYYYmmdd
      var date = (new Date(toolBox.timeFormat2Date(this.endStr)).getTime()-new Date(toolBox.timeFormat2Date(this.startStr)).getTime())/ 1000 / 60 / 60 / 24;
      if(date >= 7){
        // 周视图
        this.view = 'week';
        this.eventDurationEditable = this.eventStartEditable = this.selectable = false;
        // console.log('eventsWeek',this.eventsWeek);
        this.removeDom();
        return this.eventsWeek;
      }else{
        // 日式图
        this.view = 'day';
        this.eventDurationEditable = this.eventStartEditable = this.selectable = true;
        // console.log('eventsDay',this.eventsDay);
        return this.eventsDay;
      } 
    },
  },
  mounted() {
    // 查询班次
    this.queryClass();
    // this.classEventQuery();
    this.queryOTDelay();
    // 查询用户
    this.queryUser();
    // 查询排班计划
    this.queryPlanMaintain();
    // 活动类型大类查询
    this.actQuery();
    // 查询附属机构下的坐席
    this.auxNoQuery();
    //查询技能
    this.skillDataQuery()
    // 跳转日期
    // console.log(this.$refs.calendar.$options.calendar.gotoDate('2001-01-01'))
  },
  methods: {
    //查询技能
     async skillDataQuery() {
        let resBody = new dataQuery();
        resBody.data.FIELDCODE = 'AGENTSKILL'
        resBody.data.CurrPage = '1'
        resBody.data.PageRowNum = '100'
        let response = await request(resBody);
        if (response.SYS_HEAD.ReturnCode == "000000") {
          this.skillOption = response.BODY.FIEDATA;
          // if(this.skillOption.length>0){
          //   this.skillOption.forEach(item=>{
          //     item.SKILLLEVEL = 0.1
          //   })
          // }
          this.tableTotal = response.BODY.TotalRowNum;
        } else {
          this.$message({
            type: "error",
            message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
          })
        }
      },
    openCreateClass(){
      this.setOptions.SPID = this.PlanMaintain
      this.setOptions.checkedRole = this.checkedRole
      this.setOptions.isShow = true
    },
    DateFocus(){
      this.$forceUpdate(); 
    }, 
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.allUser.length;
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.allUser.length;
    },
    handleCheckAllChange(val) {
      this.checkedRole = val ? this.allUser : [];
      this.isIndeterminate = false;
    },
    // 去掉周下面的时间
    removeDom(){
      var that = this;
      setTimeout(function(){
        let element = document.getElementsByClassName('fc-cell-text');
        for(let x=0; x<element.length; x++) {
          if(element[x].innerText == '上午12时'){
            let parent = element[x].parentNode.parentNode.parentNode.parentNode;
            let child = element[x].parentNode.parentNode.parentNode;
            parent.removeChild(child);
            break;
          }
        }
      },0);
    },
    dateClick: function(arg) {
      console.log(
        'dateClick',
        arg.date,
        arg.resource ? arg.resource.id : '(no resource)'
      );
    },
    //点击空白日期调用
    dayClick: function(date, allDay) { 
      console.log("dayClick:",date, allDay);
    },
    // 点击日期控件上显示的事件触发的事件
    eventClick: function(eventObj) {
      // 编辑
      console.log('here',eventObj)
      this.op = 'edit';
      this.dialogVisible = true;
      this.myShow = true;
      // this.editOptions.isShow = true;
      // this.editOptions.title = '修改班表信息';
      this.ruleForm.CLASSESDATE = toolBox.timeFormat0(eventObj.event.start);
      this.ruleForm = JSON.parse(JSON.stringify(this.tableData.SCHEDULELIST[eventObj.event.id]));
      this.ruleForm.SPID = this.PlanMaintain;
      this.ruleFormDetail = JSON.parse(JSON.stringify(this.ruleForm));
      // 查询班次/加班下的班次事件
      var act = '';
      this.findAct(this.ruleForm.ACTIVITYTYPE,function(data){
        act = data;
      }); 
      if(act === '01'){
        this.queryClass();
      }else if(act === '03'){
        this.queryOTDelay();
      }else{
        console.log('error');
      }
      console.log('eventClick:',this.ruleForm);
    },
    operation(row,oper){
      this.ruleForm = JSON.parse(JSON.stringify(row));
      this.ruleForm.SPID = this.PlanMaintain;
      this.op = oper;
      this.ruleFormInfo();
      if(oper == 'edit'){
        this.update(this.ruleForm);
      }else if(oper == 'del' || oper == 'allDel'){
        this.delClick(this.ruleForm);
      }
    },
    // 查询活动大类
    findAct(data,callback){
      this.tableDataAct.forEach(item=>{
        if(data === item.ACTIVITYTYPE){
          callback(item.ACTIVITYCATEG);
        }
      })
    },
    // 新增关联班次/加班下的班次事件
    addClick(row){
      this.ruleForm = JSON.parse(JSON.stringify(this.ruleFormDetail));
      this.ruleFormInfo();
      this.op = 'add';
      this.editOptions.isShow = true;
      this.editOptions.title = '新增班表信息';
      this.editOptions.row.ruleForm = this.ruleForm;
      // 名称和事件名不可修改
      this.editOptions.startTime = this.ruleForm.SRTTIME;
      this.editOptions.endTime = this.ruleForm.ENDTIME;
      this.editOptions.skillOption = this.skillOption
      // console.log(this.ruleForm);
    },
    // 班次事件信息，点击修改
    update(row){
      this.editOptions.isShow = true;
      this.editOptions.title = '修改班表信息';
      this.editOptions.skillOption = this.skillOption
    },
    delClick(row){
      this.$confirm("此操作将永久删除该信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$refs.mychild.scheduleDel(row,this.op);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    ruleFormInfo(){
      // 如果没有关联编号,则表示这是班次或者加班，ACTIVITYID是班次或者加班
      if(this.ruleForm.TOACTIVITYID === ''){
        // 判断ACTIVITYID在班次中有木有
        this.tableDataClass.forEach((item,index)=>{
          if(item.CLASSESID == this.ruleForm.ACTIVITYID && item.ACTIVITYTYPE == this.ruleForm.ACTIVITYTYPE){
            this.classAllInfo = item;
            this.ruleForm.ClassNAME = this.ruleForm.ACTIVITYID;
          }
        });
        // 判断ACTIVITYID在加班中有木有
        this.tableDataOT.forEach((item,index)=>{
          if(item.OTID == this.ruleForm.ACTIVITYID && item.ACTIVITYTYPE == this.ruleForm.ACTIVITYTYPE){
            this.OTAllInfo = item;
            this.ruleForm.OTNAME = this.ruleForm.ACTIVITYID;
          }
        });
      }else{
        // 关联了班次或者加班编号，ACTIVITYID只能是班次事件，TOACTIVITYID是加班或班次
        // 活动大类： 01-》班次  02-》班次事件  03-》加班
        this.ruleForm.ClassEventName = this.ruleForm.ACTIVITYID;
        this.tableDataClassEvent.forEach((item,index)=>{
          if(item.CLASSESEVENTID == this.ruleForm.ClassEventName){
            this.classEventAllInfo = item;
          }
        })
        if(this.ruleForm.TOACTIVITYCATEG == '01'){
          this.tableDataClass.forEach((item,index)=>{
            if(item.CLASSESID == this.ruleForm.TOACTIVITYID){
              this.classAllInfo = item;
              this.ruleForm.ClassNAME = this.ruleForm.TOACTIVITYNAME;
            }
          });
        }else if(this.ruleForm.TOACTIVITYCATEG == '03'){
          this.tableDataOT.forEach((item,index)=>{
            if(item.OTID == this.ruleForm.TOACTIVITYID){
              this.OTAllInfo = item;
              this.ruleForm.OTNAME = this.ruleForm.TOACTIVITYNAME;
            }
          });
        }
      }
      this.ruleFormBack = JSON.parse(JSON.stringify(this.ruleForm));
      this.editOptions.row.ruleForm = this.ruleForm;
      this.editOptions.row.ruleFormBack = this.ruleFormBack;
      // console.log('eventClick:',this.classAllInfo,this.classEventAllInfo,this.OTAllInfo);
    },
    // 选择时间线 --》  新增
    select: function(arg) {
      if(arg.resource.id.indexOf('_fc')>-1){
        return;
      }
      let obj = {};
      for(var i in arg){
        obj[i] = arg[i]
      };
      // 新增选中
      this.op = 'add';
      // this.dialogVisible = true;
      // this.dialogTitle = '新增班表信息';
      this.editOptions.isShow = true;
      this.editOptions.title = '新增班表信息';
      this.editOptions.skillOption = this.skillOption
      this.ruleForm.SPID = this.PlanMaintain;
      this.ruleForm.AGENTID = obj.resource.id;
      this.ruleForm.CLASSESDATE = toolBox.timeFormat0(arg.start);
      this.ruleForm.SRTTIME = obj.startStr.substr(11, 5);
      this.ruleForm.ENDTIME = obj.endStr.substr(11, 5);
      console.log('select',this.ruleForm)
      this.editOptions.row.ruleForm = this.ruleForm;
      // console.log(arg);
    },
    eventDrop: function(arg) { // called when an event (already on the calendar) is moved
      // if(this.view == 'week'){
        arg.revert();
      // }
      // 获取到开始、结束时间、title、转换后id  _def-> resourceIds,恢复原状
      // console.log('eventDrop', arg);
      // console.log('eventDrop', this.events1);
    },
    eventDragStart(arg){
      console.log('eventDragStart', arg.event);
    },
    // 鼠标移入移出
    eventMouseEnter(arg){
      // console.log("eventMouseEnter:",arg);
      if(this.view == 'week'){
        this.msg = arg.event.title;
        this.moveStyle = {
          display: 'inline-block',
          position: 'fixed',
          top: arg.jsEvent.clientY+10+'px',
          left: arg.jsEvent.clientX+10+'px',
          zIndex: '1000',
          background: 'rgba(0,0,0,.5)',
          color: '#fff',
          padding: '5px',
          fontSize: '12px'
        }
      }
    },   
    eventMouseLeave(arg){
      // console.log("eventMouseLeave:",arg);
      this.msg = '';
      this.moveStyle = {
        display: 'none',
      }
    }, 
    dayRender(info){
      this.startStr = toolBox.timeFormat0(info.view.activeStart);
      this.endStr = toolBox.timeFormat0(info.view.activeEnd);
      this.endStr1 = toolBox.timeFormat0(info.date);
    },
    eventResizeStart(arg){
      // 当日程事件调整（resize）开始时触发
      console.log('eventResizeStart',arg);
    },
    eventResizeStop(arg){
      console.log('eventResizeStop: ',arg);
    },
    // 左右选择事件更改时间调用函数，可获取到开始、结束时间
    eventResize(arg){
      arg.revert();
      console.log('eventResize',arg);
    },
    // // 新增
    // scheduleAdd(){
    //   console.log('新增接口：',this.ruleForm);
    //   this.loading = true;
    //   let resBody = new scheduleAdd();
    //   resBody.data.SPID = this.PlanMaintain;
    //   resBody.data.AGENTID = this.ruleForm.AGENTID;
    //   resBody.data.CLASSESDATE = this.ruleForm.CLASSESDATE;
    //   resBody.data.ACTIVITYTYPE = this.ruleForm.ACTIVITYTYPE; 
    //   resBody.data.ACTIVITYID = this.ruleForm.ACTIVITYID; 
    //   resBody.data.SRTTIME = this.ruleForm.SRTTIME; 
    //   resBody.data.ENDTIME = this.ruleForm.ENDTIME; 
    //   resBody.data.TOACTIVITYID = this.ruleForm.TOACTIVITYID;
    //   resBody.data.TOACTIVITYNAME = this.ruleForm.TOACTIVITYNAME;
    //   resBody.data.TOACTIVITYCATEG = this.ruleForm.TOACTIVITYCATEG;
    //   resBody.data.TOACTIVITYTYPE = this.ruleForm.TOACTIVITYTYPE;
    //   request(resBody)
    //     .then(response => {
    //       if (response.SYS_HEAD.ReturnCode === "000000") {
    //         this.loading = false;
    //         this.$message({
    //           type: "success",
    //           message: "新增成功"
    //         });
    //         this.queryModel();
    //         this.closeDialog('ruleForm');
    //       }else{
    //         this.loading = false;
    //         this.$message({
    //           type: "error",
    //           message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
    //         })
    //       }
    //     })
    //     .catch(error => {
    //       this.loading = false;
    //     });
    // },
    // // 修改
    // scheduleEdit(){
    //   console.log('修改接口：',this.ruleForm);
    //   this.loading = true;
    //   let resBody = new scheduleEdit();
    //   resBody.data.SPID = this.PlanMaintain;
    //   resBody.data.AGENTID = this.ruleForm.AGENTID;
    //   resBody.data.ORIGCLASSESDATE = this.ruleFormBack.CLASSESDATE;
    //   resBody.data.ORIGACTIVITYTYPE = this.ruleFormBack.ACTIVITYTYPE; 
    //   resBody.data.ORIGACTIVITYID = this.ruleFormBack.ACTIVITYID; 
    //   resBody.data.NEWCLASSESDATE = this.ruleForm.CLASSESDATE; 
    //   resBody.data.NEWACTIVITYTYPE = this.ruleForm.ACTIVITYTYPE; 
    //   resBody.data.NEWACTIVITYID = this.ruleForm.ACTIVITYID;
    //   resBody.data.NEWSRTTIME = this.ruleForm.SRTTIME;
    //   resBody.data.NEWENDTIME = this.ruleForm.ENDTIME;
    //   resBody.data.TOACTIVITYID = this.ruleForm.TOACTIVITYID;
    //   resBody.data.TOACTIVITYNAME = this.ruleForm.TOACTIVITYNAME;
    //   resBody.data.TOACTIVITYCATEG = this.ruleForm.TOACTIVITYCATEG;
    //   resBody.data.TOACTIVITYTYPE = this.ruleForm.TOACTIVITYTYPE;
    //   request(resBody)
    //     .then(response => {
    //       if (response.SYS_HEAD.ReturnCode === "000000") {
    //         this.loading = false;
    //         this.$message({
    //           type: "success",
    //           message: "修改成功"
    //         });
    //         this.queryModel();
    //         this.closeDialog('ruleForm');
    //       }else{
    //         this.loading = false;
    //         this.$message({
    //           type: "error",
    //           message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
    //         })
    //       }
    //     })
    //     .catch(error => {
    //       this.loading = false;
    //     });
    // },
    //查询临时班表
    queryModel(QUREYSRTDATE,QUREYENDDATE) {
      this.loading = true;
      this.eventsDay = [];
      this.eventsWeek = [];
      this.resources = [];
      let resBody = new scheduleQuery();
      resBody.data.SPID = this.PlanMaintain;
      resBody.data.AGENTIDLISTSTR = this.checkedRole.join(',');
      resBody.data.QUREYSRTDATE = QUREYSRTDATE || this.startStr;
      resBody.data.QUREYENDDATE = QUREYENDDATE || this.endStr1;
      request(resBody)
        .then(response => {
          if (response.SYS_HEAD.ReturnCode === "000000") {
            this.tableData = response.BODY;
            var table = [];
            this.tableData.SCHEDULELIST.forEach(item=>{
              if(!item.TOACTIVITYID){
                table.push(item);
              } 
            });
            this.tableData.SCHEDULELIST = table;
            // 人员列表
            this.tableData.AGENTINFO.forEach((item,index)=>{
              if(item.AGENTID){
                this.resources.push({'id':item.AGENTID,'title':item.AGENTNAME});
              }
            });
            // 事件列表
            this.tableData.SCHEDULELIST.forEach((item,index)=>{
              var CLASSESDATE = toolBox.timeFormat2Date( item.CLASSESDATE);
              this.eventsDay.push({
                'id': index+'',
                'resourceId': item.AGENTID,
                'start': CLASSESDATE+' '+item.SRTTIME,
                'end': CLASSESDATE+' '+item.ENDTIME,
                'title': item.ACTIVITYNAME,
                'color': item.CALCOLOUR,
              });
              this.eventsWeek.push({
                'id': index+'',
                'resourceId': item.AGENTID,
                'start': CLASSESDATE,
                'end': CLASSESDATE,
                'title': item.SRTTIME+'-'+item.ENDTIME+' '+item.ACTIVITYNAME,
                'color': item.CALCOLOUR,
              });
            })
          } else {
            this.$message({
              message: response.SYS_HEAD.ReturnMessage,
              type: 'error  '
            });
          }
        })
        .catch(error => {
          console.log("error", error);
        })
      this.loading = false;
    },
    // 查询该班次/加班下的所有班次事件
    queryModel1() {
      this.loading = true;
      let resBody = new scheduleQuery();
      resBody.data.SPID = this.PlanMaintain;
      resBody.data.AGENTIDLISTSTR = this.ruleFormDetail.AGENTID;
      resBody.data.TOACTIVITYTYPE = this.ruleFormDetail.ACTIVITYTYPE;
      resBody.data.QUREYSRTDATE = this.ruleFormDetail.CLASSESDATE;
      resBody.data.QUREYENDDATE = this.ruleFormDetail.CLASSESDATE;
      request(resBody)
        .then(response => {
          if (response.SYS_HEAD.ReturnCode === "000000") {
            this.tableDataDetail = response.BODY;
            console.log('lalalalala',this.tableDataDetail.SCHEDULELIST)
            if(!response.BODY.SCHEDULELIST[0].ACTIVITYID){
              this.tableDataDetail.SCHEDULELIST = [];
            }
            // console.log('queryMOdel1',this.ruleFormDetail);
          } else {
            this.$message({
              message: response.SYS_HEAD.ReturnMessage,
              type: 'error  '
            });
          }
        })
        .catch(error => {
          console.log("error", error);
        })
      this.loading = false;
    },
    // 班次事件详情弹窗打开
    openDialog(){

    },
    // 班次事件详情弹窗关闭
    closeDialog() {
      this.dialogVisible = false;
      this.tableDataDetail = [];
      this.ruleFormDetail = [];
      this.ruleForm = {},
      this.ruleFormBack = {};
      this.classAllInfo = [];
      this.classEventAllInfo = [];
      this.OTAllInfo = [];
      this.tableDataClassEvent = [];
      this.myShow = false;
      this.queryModel();
      if(this.op == 'allDel'){
        this.queryModel();
      }
    },
    // 新增or编辑 保存
    // submitForm(formName) {
    //   this.$refs[formName].validate((valid) => {
    //     if (valid) {
    //       if(this.ruleForm.ClassEventName === '' || this.ruleForm.ClassEventName == undefined || this.ruleForm.ClassEventName == '-1'){
    //         // 如果只选择班次或者加班，未选择班次事件，活动类型则给班次或者加班得
    //         if((this.ruleForm.ClassNAME === '' || this.ruleForm.ClassNAME == undefined || this.ruleForm.ClassNAME == '-1')){
    //           this.ruleForm.ACTIVITYID = this.OTAllInfo.OTID;
    //           this.ruleForm.ACTIVITYTYPE = this.OTAllInfo.ACTIVITYTYPE;
    //         }else{
    //           this.ruleForm.ACTIVITYID = this.classAllInfo.CLASSESID;
    //           this.ruleForm.ACTIVITYTYPE = this.classAllInfo.ACTIVITYTYPE;
    //         } 
    //       }else{
    //         if((this.ruleForm.ClassNAME === '' || this.ruleForm.ClassNAME == undefined || this.ruleForm.ClassNAME == '-1') &&
    //           (this.ruleForm.OTNAME === '' || this.ruleForm.OTNAME == undefined || this.ruleForm.OTNAME == '-1')){
    //           this.$message({
    //             type: "error",
    //             message: "请选择班次或者加班"
    //           })
    //           return;
    //         }
    //         // 如果选择班次事件，班次或者加班必须选择，活动类型则给班次事件得,所属活动给加班或者班次的
    //         this.ruleForm.ACTIVITYID = this.classEventAllInfo.CLASSESEVENTID;
    //         this.ruleForm.ACTIVITYTYPE = this.classEventAllInfo.ACTIVITYTYPE;
    //         var TOACTIVITYTYPE = '';
    //         if((this.ruleForm.ClassNAME === '' || this.ruleForm.ClassNAME == undefined || this.ruleForm.ClassNAME == '-1')){
    //           this.ruleForm.TOACTIVITYID = this.OTAllInfo.OTID;
    //           this.ruleForm.TOACTIVITYNAME = this.OTAllInfo.OTNAME;
    //           this.ruleForm.TOACTIVITYTYPE = this.OTAllInfo.ACTIVITYTYPE;
    //           let act=this.findAct(this.OTAllInfo.ACTIVITYTYPE,function(data){
    //             TOACTIVITYTYPE = data;
    //           }); 
    //           this.ruleForm.TOACTIVITYCATEG = TOACTIVITYTYPE;
    //         }else{
    //           this.ruleForm.TOACTIVITYID = this.classAllInfo.CLASSESID;
    //           this.ruleForm.TOACTIVITYNAME = this.classAllInfo.CLASSESNAME;
    //           this.ruleForm.TOACTIVITYTYPE = this.classAllInfo.ACTIVITYTYPE;
    //           let act=this.findAct(this.classAllInfo.ACTIVITYTYPE,function(data){
    //             TOACTIVITYTYPE = data;
    //           }); 
    //           this.ruleForm.TOACTIVITYCATEG = TOACTIVITYTYPE;
    //         } 
    //       }
    //       if(!this.ruleForm.ACTIVITYID){
    //         this.$message({
    //           type: "error",
    //           message: "请选择活动类型名称"
    //         })
    //         return;
    //       }
    //       var c1 = Date.parse('2008-08-08 '+this.ruleForm.SRTTIME); //'2008-08-08'这个日期随便给
    //       var c2 = Date.parse('2008-08-08 '+this.ruleForm.ENDTIME);
    //       if (c1 > c2) {
    //         this.$message({
    //           type: "error",
    //           message: "开始时间不能大于结束时间"
    //         })
    //         return;
    //       }
    //       console.log('保存按钮',this.ruleForm,this.ruleFormBack);
    //       if(this.op=='add'){
    //         this.scheduleAdd();
    //       }else{
    //         this.scheduleEdit();
    //       }
    //     } else {
    //       console.log('error submit!!');
    //       return false;
    //     }
    //   });
    // },
    // 删除班表
    // scheduleDel(){
    //   this.loading = true;
    //   let resBody = new scheduleDel();
    //   resBody.data.SPID = this.PlanMaintain;
    //   resBody.data.AGENTID = this.ruleForm.AGENTID;
    //   resBody.data.CLASSESDATE = this.ruleForm.CLASSESDATE;
    //   resBody.data.ACTIVITYTYPE = this.ruleForm.ACTIVITYTYPE; 
    //   resBody.data.ACTIVITYID = this.ruleForm.ACTIVITYID; 
    //   resBody.data.TOACTIVITYID = this.ruleForm.TOACTIVITYID;
    //   resBody.data.TOACTIVITYNAME = this.ruleForm.TOACTIVITYNAME;
    //   resBody.data.TOACTIVITYCATEG = this.ruleForm.TOACTIVITYCATEG;
    //   resBody.data.TOACTIVITYTYPE = this.ruleForm.TOACTIVITYTYPE;
    //   request(resBody)
    //     .then(response => {
    //       if (response.SYS_HEAD.ReturnCode === "000000") {
    //         this.loading = false;
    //         this.$message({
    //           type: "success",
    //           message: "删除成功"
    //         });
    //         this.queryModel();
    //         this.closeDialog('ruleForm');
    //       }else{
    //         this.loading = false;
    //         this.$message({
    //           type: "error",
    //           message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
    //         })
    //       }
    //     })
    //     .catch(error => {
    //       this.loading = false;
    //     });
    // },
    queryUser() { //查询用户表格
      let resBody = new userQuery();
      resBody.data.AGENTID = '';
      resBody.data.AGENTNAME = '';
      resBody.data.BRANCHNO = this.BRANCHNO;
      resBody.data.CurrPage = '1'||this.currentPageUser; 
      resBody.data.PageRowNum = '100' || this.pageSize; 
      request(resBody)
        .then(response => {
          if (response.SYS_HEAD.ReturnCode === "000000") {
            this.userData = response.BODY.AGENTDATA;
          }else{
            this.$message({
              type: "error",
              message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
            })
          }
        })
        .catch(error => {
          this.loading = false;
        });
    },
    // 点击用户操作
    getUserInfo(item) {
      console.log(this.checkedRole.join(","));
    },
    // 查询排班计划
    async queryPlanMaintain() {
      let resBody = new queryPlanMaintain();
      resBody.data.BRANCHNO = this.BRANCHNO;
      resBody.data.SPNAME = '';
      resBody.data.SRTDATE = '';
      resBody.data.SPID = '';
      resBody.data.CurrPage = '1'; 
      resBody.data.PageRowNum = '100' || this.pageSize;
      let response = await request(resBody);
      if (response.SYS_HEAD.ReturnCode == "000000") {
        // 查询出数据
        this.tableDataPlan = toolBox.removal(response.BODY.RSPSTRUCT,'SPID');
        // this.tableTotal = response.BODY.TotalRowNum;
      } else {
        this.$message({
          type: "error",
          message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
        });
      }
    },
    // selectChange(val){
    //   this.checkedRole = [];
    //   this.PlanMaintain = '';
    //   if(val.length>0){
    //     this.queryPlanMaintain();
    //     this.queryUser();
    //   }
    // },
    // 班次查询
    async queryClass() {
      let resBody = new classQuery()
      resBody.data.BRANCHNO = this.BRANCHNO;
      resBody.data.CLASSESID = this.ruleForm.ACTIVITYID || '';
      resBody.data.CLASSESNAME = '';
      resBody.data.ACTIVITYTYPE = '';
      resBody.data.CurrPage = '1';
      resBody.data.PageRowNum = '100';
      let response = await request(resBody);
      if (response.SYS_HEAD.ReturnCode == "000000") {
        // this.tableTotal = response.BODY.TotalRowNum;
        if(this.ruleForm.ACTIVITYID){
          this.tableDataClassEvent = response.BODY.RSPSTRUCT[0].EVENT;
          this.editOptions.row.tableDataClassEvent = this.tableDataClassEvent;
        }else{
          this.tableDataClass = response.BODY.RSPSTRUCT;
        }
      } else {
        this.$message({
          type: "error",
          message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
        })
      }
    },
    // 班次变化时拿到活动类型
    // handleClassChange(val){
    //   this.classAllInfo = [];
    //   for(var i=0;i<this.tableDataClass.length;i++){
    //     if(this.tableDataClass[i].CLASSESID == val){
    //       this.classAllInfo = this.tableDataClass[i];
    //       break;
    //     }
    //   }
    //   this.$forceUpdate();
    //   // console.log(val,this.ruleForm.ClassEventNAME);
    // },
    // 班次事件变化时拿到活动类型
    // handleClassEventChange(val){
    //   this.classEventAllInfo = [];
    //   for(var i=0;i<this.tableDataClassEvent.length;i++){
    //     if(this.tableDataClassEvent[i].CLASSESEVENTID == val){
    //       this.classEventAllInfo = this.tableDataClassEvent[i];
    //       break;
    //     }
    //   }
    //   this.$forceUpdate();
    //   // console.log(val,this.ruleForm.ClassNAME);
    // },
    // 班次事件变化时拿到活动类型
    // handleOTChange(val){
    //   this.OTAllInfo = [];
    //   for(var i=0;i<this.tableDataOT.length;i++){
    //     if(this.tableDataOT[i].OTID == val){
    //       this.OTAllInfo = this.tableDataOT[i];
    //       break;
    //     }
    //   }
    //   this.$forceUpdate();
    //   console.log(val,this.ruleForm.ClassNAME);
    // },
    // 班次事件查询
    async classEventQuery() {
      let resBody = new classEventQuery()
      resBody.data.BRANCHNO = this.BRANCHNO;
      resBody.data.CLASSESEVENTID = '';
      resBody.data.CLASSESEVENTNAME = '';
      resBody.data.CurrPage = '1'; 
      resBody.data.PageRowNum = '100'; 
      let response = await request(resBody);
      if (response.SYS_HEAD.ReturnCode == "000000") {
        this.tableDataClassEvent = response.BODY.RSPSTRUCT
      } else {
        this.$message({
          type: "error",
          message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
        })
      }
    },
    // 加班查询
    async queryOTDelay() {
      this.loading = true;
      let resBody = new queryOTDelay();
      resBody.data.BRANCHNO = this.BRANCHNO;
      resBody.data.OTID = this.ruleForm.ACTIVITYID || '';
      resBody.data.OTNAME = '';
      resBody.data.ACTIVITYTYPE = '';
      resBody.data.PageFlag = '4';
      resBody.data.CurrPage = '1';
      resBody.data.PageRowNum = '100';
      let response = await request(resBody);
      this.loading = false;
      if (response.SYS_HEAD.ReturnCode == "000000") {
        if(this.ruleForm.ACTIVITYID){
          this.tableDataClassEvent = response.BODY.RSPSTRUCT[0].EVENT;
          this.editOptions.row.tableDataClassEvent = this.tableDataClassEvent;
        }else{
          this.tableDataOT = response.BODY.RSPSTRUCT;
        }
      } else if (response.SYS_HEAD.ReturnCode == "ARBFQ001") {
        this.tableDataOT = [];
      } else {
        this.$message({
          type: "error",
          message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
        });
      }
    },
    // 活动类型查询
    async actQuery() {
      let resBody = new actQuery()
      resBody.data.ACTIVITYTYPE = '';
      resBody.data.ACTIVITYTYPENAME = '';
      resBody.data.ACTIVITYCATEG = '';
      resBody.data.CurrPage = '1';
      resBody.data.PageRowNum = '100';
      let response = await request(resBody);
      if (response.SYS_HEAD.ReturnCode == "000000") {
        this.tableDataAct = response.BODY.RSPSTRUCT;
      } else {
        this.$message({
          type: "error",
          message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
        })
      }
    },
    // 班表发布
    async scheduleRelease(){
      let resBody = new scheduleRelease();
      resBody.data.SPID = this.PlanMaintain;
      let response = await request(resBody);
      if (response.SYS_HEAD.ReturnCode == "000000") {
        this.$message({
          type: "success",
          message: "发布成功"
        });
      } else {
        this.$message({
          type: "error",
          message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
        });
      }
    },
    getBranch(data){
      // console.log(data);
      this.BRANCHNO = data.BRANCHNO;
      this.BRANCHNAME = data.BRANCHNAME;
      this.isIndeterminate = false;
      this.checkAll = false;
      this.checkedRole = [];
      this.PlanMaintain = '';
      if(data){
        this.queryPlanMaintain();
        this.queryUser();
        this.queryClass();
        // this.classEventQuery();
        this.queryOTDelay();
        this.auxNoQuery();
      }
    },
    // 查询附属机构下的坐席
    async auxNoQuery() {
      this.loading = true;
      let resBody = new auxNoQuery();
      resBody.data.AUXNO = this.BRANCHNO;
      resBody.data.PageFlag = '4';
      resBody.data.CurrPage = '1';
      resBody.data.PageRowNum = '100';
      let response = await request(resBody);
      this.loading = false;
      if (response.SYS_HEAD.ReturnCode == "000000") {
        response.BODY.AGENTDATA.forEach(item=>{
          item.color = true;
          this.userData.push(item);
        })
      } else {
        this.$message({
          type: "error",
          message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
        });
      }
    },
  }
};
</script>

<style lang='scss'>
@import '../../../styles/core/main.css';
@import '../../../styles/timeline/main.css';
@import '../../../styles/resource-timeline/main.css';
.demo-app {
  font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  font-size: 14px;
}
.demo-app-top {
  margin: 0 0 3em;
}
.demo-app-calendar {
  margin: 0 auto;
  max-width: 900px;
}
.fc-license-message{
  display: none;
}
.fc-time-wrap,.fc-title-wrap{
  color: #000;
}
.scheduling-system{
  .el-checkbox__inner{
    top: 2px;
  }
  .el-date-editor.el-input{
    width: 100%;
  }
  .el-input--prefix .el-input__inner{
    padding-left: 27px;
  }
  .el-checkbox-group {
    padding: 0 10px 10px;
  }

  .el-checkbox:first-child {
    margin-left: 10px;
  }

  .el-checkbox {
    display: inline-block;
    margin-bottom: 10px;
    // width: 90%;
    display: flex;
    height: auto;
    padding: 6px 15px 6px 10px;
    white-space: inherit;
  }
}
</style>
<style lang="scss" scoped>
.agentStyle{
  position: relative;
}
.extraBranchStyle{
  color:#ef4949;
  font-size:12px;
  position: absolute;
  top:2px;
  // left: 2px;
  margin-left:3px;
}
</style>
